﻿
using HBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace hconnect {
    public abstract class ExchangeBaseTask :ZtTask {

        public abstract ExchangeStatus getA();
        public abstract ExchangeStatus getB();
        public override bool excute() {
            ExchangeStatus statusA = getA();
            ExchangeStatus statusB = getB();
            if( statusA != ExchangeStatus.InIng && statusB == ExchangeStatus.OutIng ) {
                console(InfoCode.consle_exchange_runed,"交换异常 A:" + statusA + "B:" + statusB + "b停止出");
                bFinishOut();
            } else if( statusB != ExchangeStatus.InIng && statusA == ExchangeStatus.OutIng ) {
                console(InfoCode.consle_exchange_runed, "交换异常 A:" + statusA + "B:" + statusB + "A停止出");
                aFinishOut();
            } else if( statusA == ExchangeStatus.Idle && statusB == ExchangeStatus.OutReady ) {
                console(InfoCode.consle_exchange_runed, "A 转动接托盘 ");
                aDoIn();
            } else if( statusA == ExchangeStatus.InIng && statusB == ExchangeStatus.OutReady ) {//b正在向a运货
                console(InfoCode.consle_exchange_runed, "B 转动托盘 ");
                bDoOut();
            } else if( statusA == ExchangeStatus.Ined && statusB == ExchangeStatus.OutIng ) {//b准备到a
                console(InfoCode.consle_exchange_runed, "B 完成出托盘 ");
                bFinishOut();
            } else if( statusA == ExchangeStatus.OutReady && statusB == ExchangeStatus.Idle ) {//a向b上一个完成
                console(InfoCode.consle_exchange_runed, "B 接托盘 ");
                bDoIn();
            } else if( statusA == ExchangeStatus.OutReady && statusB == ExchangeStatus.InIng ) {//a向b上一个完成
                console(InfoCode.consle_exchange_runed, "A 出托盘 ");
                aDoOut();
            } else if( statusA == ExchangeStatus.OutIng && statusB == ExchangeStatus.Ined ) {//a准备到b
                console(InfoCode.consle_exchange_runed, "A 出托盘完成 ");
                aFinishOut();
            }
            return true;
        }

        public abstract void aDoOut();
        public abstract void aFinishOut();
        public abstract void bDoIn();
        public abstract void aDoIn();
        public abstract void bDoOut();
        public abstract void bFinishOut();
    }
}
